def triangle(n):
    l = [[1], [1, 1]]
    for i in range(2, n):
        ll = [1]
        for ii in range(len(l[i - 1]) - 1):
            ll.append(l[i - 1][ii] + l[i - 1][ii + 1])
        ll.append(1)
        l.append(ll)
    for i in range(n):
        for space in range(i, n - 1):
            print(" ", end = "")
        for ii in range(len(l[i])):
            print(l[i][ii], " ", end = "")
        print()
triangle(3)
